B BMovAsm PRG formatted GEOS file V1.0 Star NX-10 OP V2.0 or higher BMOVASM BLASTER'S CONVERTER V2.5 geosMac BMovHdr.rel Write Image V2.1 geoWrite V2.1 ; **************************************************************************** ; BMover -- move stuff between banks, call a routine in another bank ; Robert A. Knop Jr., Usenet Hacking Mag Issue #2 ; Note- be sure to set the constants DESTBANK, FIRSTADDR, NUMBLOCKS, etc. ; to reflect the moving you want to do. Be careful NOT to ; overlap $ff00!! ; **************************************************************************** .if Pass1 .noeqin @.include geosSym .include geosMac .eqin .endif DESTBANK = 0 ;Bank to copy data to / run routine in (RAM0) DESTCFG = %00111111 ;Config. ($ff00 value) " " " " " " " " " " " " SRCADDR = $0400 ;Source address in FrontRAM ($400=code space) FIRSTADDR = $2000 ;First destination address NUMBLOCKS = $04 ;# of blocks to copy BLOCKSIZE = $2000 ;size of each block copied BF = $80 ;c128 bitmap doubling flags WLF = $8000 WRF = $a000 dT == a1 ;ZP variable : dT = time elapsed dTL == a1L dTH == a1H TODTenths == $dc08 ;CIA #1 TOD registers... TODSecs == $dc09 TODMins == $dc0a TODHours == $dc0b Start: LoadW r0,Choose3Box jsr DoDlgBox ;Put up a Dialogue Box selecting the move to do CmpBI r0L,$10 bne 10$ jsr KernalMove bra Start 10$ cmp #$11 bne 90$ jsr CallFarRout bra Start @jmp EnterDeskTop BI_X_0,DBI_Y_2 .byte NULL Yup: .byte "Verifcation successful",0 Nope: .byte "Verify error!",0 @Time2Tenths: ;Returns CIA #1 TOD since last hour as tenths in r0; hour in r1L lda TODHours bpl 10$ ;if AM, no need to convert to 24 hours and #%01111111 ;clear AM/PM flag sed ;TOD is stored in Binary Coded Decimal... add #12 ;Convert to 24 hours cld ;...but otherwise, I know of no use for BCD!!! 10$ jsr BCD2binary sta r1L ;Save starting hour to r1L lda TODMins jsr BCD2binary jsr Mult10 jsr Mult60 ;r0=mins*60*10 MoveW r0,r2 ;r2 holds minutes (in tenths of secs) lda TODSecs jsr BCD2binary jsr Mult10 ;r0=secs*10 AddB TODTenths,r0L ;Since 10ths<10, BCD is same as binary bcc 20$ ; (NOTE: TODTenths MUST be read last!) inc r0H ;r0 now has 10*secs + tenths 20$ AddW r2,r0 ;r0 now has starting time in 10ths of seconds @ rts ; since the last hour (which is in r1L) @StartTime: jsr Time2Tenths MoveW r0,StartT MoveB r1L,StartH @rts @DeltaT: ;Subtract starting time from current time, save as a # of tenths in dT jsr Time2Tenths MoveW r0,dT ;Save end time in dT lda r1L sub StartH ;Subtract diffence in hours beq 10$ ;if diff., add the diff. to ending time jsr Mult10 jsr Mult60 jsr Mult60 ;Now hour diff (in tenths of secs) is in r0 AddW r0,dT ;Add this diff to dT 10$ SubW StartT,dT ;Now dT has difference in time @ rts @PutTime: LoadW r0,TimeBox ;Writes out dT as a decimal number jsr DoDlgBox @rts TimeBox: .byte DEF_DB_POS|1 .byte DB_USR_ROUT .word WriteTime .byte DBTXTSTR .byte TXT_LN_X,TXT_LN_1_Y .word TimeElapsed .byte OK,DBI_X_0,DBI_Y_2 ;OK icon .byte NULL TimeElapsed: .byte "10ths of seconds elapsed:",0 WriteTime: MoveW dT,r0 ;Number to write in r0 LoadW r11,WLF+DEF_DB_LEFT+TXT_LN_X ;X position LoadB r1H,DEF_DB_TOP+TXT_LN_3_Y ;Y position lda #SET_LEFTJUST|SET_SUPRESS ;Formatting code jsr PutDecimal @ rts BCD2binary: pha ;Convert a from BCD to normal binary and #%00001111 sta a0L ;Save lower nybble lsr a lsr a BCD2binary: pha ;Convert a from BCD to normal binary and #%00001111 sta a0L ;Save lower nybble lsr a lsr a lsr a lsr a ;Shift the upper nybble down to lower nybble sta a0H asl a ;And multiply by 10 asl a asl a add a0H adc a0H add a0L ;add lower nybble back @rts Mult10: sta r0L ;r0=a*10 LoadB r0H,0 LoadW r1,10 ldx #r0 ;x points to operand1 (and result) ldy #r1 ;y points to operand2 jsr DMult @rts Mult60: LoadW r1,60 ;r0=r0*60 ldx #r0 ldy #r1 jsr DMult @rts @KernalMove: ;Copies NUMBLOCKS copies of BG screen to DESTBANK jsr StartTime ;Save starting time LoadB a0L,NUMBLOCKS ;a0L - a counter in zero page LoadW r0,$6000 ;r0 - source of mo @KernalMove: ;Copies NUMBLOCKS copies of SRCADDR to DESTBANK jsr StartTime ;Save starting time LoadB a0L,NUMBLOCKS ;a0L - a counter in zero page LoadW r0,SRCADDR ;r0 - source of move LoadW r1,FIRSTADDR ;r1 - destination of move LoadW r2,BLOCKSIZE ;r2 - size of move LoadB r3L,1 ;r3L - Source Bank (FrontRAM) LoadB r3H,DESTBANK ;r3H - Destination Bank 10$ nop @.if 0 jsr Saver0r3 ;This is debugging code -- this sort of thing LoadW r0,DBBox ; is especially useful since geoDebugger has jsr DoDlgBox ; hangups (pun intended) over MoveBData jsr Restr0r3 ; (sometimes- that's the most infuriating part!) .endif jsr MoveBData ; (r0-r3 returned unchanged) dec a0L ;decrement our counter beq 20$ ;If 0, we're done AddVW BLOCKSIZE,r1 ;Point to next block in destination bra 10$ 20$ jsr DeltaT ;Calculate time elapsed jsr CheckBData ;Make sure transfers OK @jmp PutTime ;Report the time elapsed @CheckBData: LoadB a0L,NUMBLOCKS ;a0L - a counter in zero page LoadW r0,SRCADDR ;r0 - "source" of verify LoadW r1,FIRSTADDR ;r1 - "destination" of verify LoadW r2,BLOCKSIZE ;r2 - size of verify LoadB r3L,1 ;r3L - "Source" Bank (FrontRAM) LoadB r3H,DESTBANK ;r3H - "Destination" Bank 10$ jsr VerifyBData ; (r0-r3 returned unchanged) cpx #$00 ;Check for verify errors (x=$ff if errors) bne 30$ dec a0L ;decrement our counter beq 20$ ;If 0, we're done AddVW BLOCKSIZE,r1 ;Point to next 8K in destination bra 10$ @rts 30$ LoadW r0,VerErrBox ;Report verify error jsr DoDlgBox @rts VerErrBox: .byte DEF_DB_POS|1 .byte DBTXTSTR .byte TXT_LN_X,TXT_LN_1_Y .word VerErrText .byte OK,DBI_X_0,DBI_Y_2 .byte NULL VerErrText: .byte "Verify Error in moved data!",0 @.if 0 ;A page of debugging code DBBox: .byte DEF_DB_POS .byte DB_USR_ROUT .word PutDBRegs .byte DBTXTSTR,TXT_LN_X,TXT_LN_1_Y DBStr: .word DBText0 .byte OK,DBI_X_0,DBI_Y_2 .byte NULL DBText0: .byte "About to Move:",0 PutDBRegs: LoadB r1H,DEF_DB_TOP+TXT_LN_2_Y LoadB a0L,a2 10$ LoadW r11,WLF+DEF_DB_LEFT+TXT_LN_X ldx a0L cpx #a6 bcs 20$ lda $01,x jsr PutHex ldx a0L lda $00,x jsr PutHex inc a0L inc a0L AddVB 10,r1H bra 10$ @rts PutHex: pha lsr a lsr a lsr a lsr a lda HexNums,x jsr PutChar and #%00001111 lda HexNums,x jsr PutChar @rts HexNums: .byte "0123456789abcdef" Saver0r3: MoveW r0,a2 MoveW r1,a3 MoveW r2,a4 MoveW r3,a5 MoveB a0L,a6L ;Save the counter! @ rts Restr0r3: MoveW a2,r0 MoveW a3,r1 MoveW a4,r2 MoveW a5,r3 MoveB a6L,a0L @rts @.endif time elapsed jsr CheckBData ;Make sure transfers OK @jmp PutTime ;Report the time elapsed @CheckBData: @CallFarRout: jsr StartTime ;For kicks, time the whole thing LoadW r0,Mover ;First, install the Mover in DESTBANK LoadW r1,$2000 ; at location $2000 LoadW r2,EndMover-Mover LoadB r3L,1 ;FrontRAM LoadB r3H,DESTBANK jsr MoveBData ;Copy BG screen to $6000 in DESTBANK LoadW r0,$6000 ; (so that it is different from what we put LoadW r1,$6000 ; at $4000) LoadW r2,$2000 jsr MoveBData LoadW r0,$0400 ;Copy this code space etc. to $4000 in DESTBANK LoadW r1,$4000 ; (this we will move using a routine in DESTBANK jsr MoveBData ; to $6000 in DESTBANK) @sei ;Disable interrupts for safety ldx #<(EndZPJSR-ZPJSR-1) 10$ lda ZPJSR,x ;move ZPJSR to $02 sta $02,x bpl 10$ .byte $20,$02,$00 ;jsr $0002 @cli ;Restore interrupts jsr DeltaT ;Save the end time before the verify check LoadW r0,$0400 ;Make sure that $6000 now matches code space LoadW r1,$6000 LoadW r2,$2000 LoadB r3L,1 LoadB r3H,DESTBANK jsr VerifyBData cpx #$00 beq 20$ ;x!=$00 means verify error LoadW r0,JsrBox jsr DoDlgBox ;Report any verify error that has occurred 20$ jsr PutTime ;Report the time it took @rts @JsrBox: .byte DEF_DB_POS|1 .byte DBTXTSTR,TXT_LN_X,TXT_LN_1_Y .word Nope .byte OK .byte DBI_X_0,DBI_Y_2 .byte NULL Nope: .byte "Verify error!",0 `8` &H @Mover: LoadW r14,$4000 ;Moves 8K at $4000 to $6000 LoadW r15,$6000 ;This code is relocated to $2000 in DESTBANK ldy #$00 10$ lda (r14),y sta (r15),y bne 10$ inc r14H inc r15H CmpBI r14H,$80 ;Have we done all 32 pages yet? bcc 10$ @ rts @EndMover: @ZPJSR: lda $ff00 ;A JSRFAR sort of routine that goes in ZP; pha ;Save initial configuration for later restore lda #DESTCFG sta $ff00 jsr $2000 ;jsr to $2000 sta $ff00 @rts EndZPJSR: a ; to $6000 in DESTBANK) @sei ;Disable interrupts for safety ldx #<(EndZPJSR-ZPJSR-1) 10$ lda ZPJSR,x ;move ZPJSR to $02 sta $02,x bpl 10$ .byte $20,$02,$00 ;jsr $0002 @cli ;Restore interrupts LoadW r0,$0400 ;M Choose3Box: .byte DEF_DB_POS|1 .byte DBTXTSTR ; @Please Select Option .byte TXT_LN_X,2*8 .word selOptText .byte DBUSRICON ;Icon 1 .byte BF+2,3*8 .word ChIcon1 .byte DBTXTSTR ;...associated text .byte (2+6)*8+7,3*8+10 .word ChText1 .byte DBUSRICON ;Icon 2 .byte BF+2,6*8 .word ChIcon2 .byte DBTXTSTR ;...associated text .byte (2+6)*8+7,6*8+10 .word ChText2 .byte DBUSRICON ;Icon 3 .byte BF+2,9*8 .word ChIcon3 .byte DBTXTSTR ;...associated text .byte (2+6)*8+7,9*8+10 .word ChText3 .byte NULL ChIcon1: .word ChPic1 .byte 0,0 ;ignored .byte BF+SYSDBI_WIDTH,SYSDBI_HEIGHT .word ChRout1 ChIcon2: .word ChPic2 .byte 0,0 .byte BF+SYSDBI_WIDTH,SYSDBI_HEIGHT .word ChRout2 ChIcon3: .word ChPic3 .byte 0,0 .byte BF+SYSDBI_WIDTH,SYSDBI_HEIGHT .word ChRout3 ChRout1: lda #$10 bra EndCh ChRout2: lda #$11 bra EndCh ChRout3: lda #$12 EndCh: sta sysDBData jmp RstrFrmDialog selOptText: .byte BOLDON,"Please Select Option:",PLAINTEXT,0 ChText1: .byte "repeatedly store BG",0 ChText2: .byte "call extrabankal routine",0 ChText3: .byte "to DeskTop",0 ChPic1: ChPic2: ChPic3: @.ramsect StartH: .block 1 ;Storage of starting hour StartT: .block 2 ;Storage @.ramsect StartH: .block 1 ;Storage of starting hour StartT: .block 2 ;Storage of starting tenths since last hour Saved506: .block 1 ;Temporary storage of MMURCR da #SET_LEFTJUST|SET_SUPRESS ;Formatting code jsr PutDecimal